package com.icavy.yousha.action;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import com.icavy.yousha.entity.User;
import com.icavy.yousha.service.UserService;

@Controller
@RequestMapping("/login")
public class LoginAction {
    
    @Resource
    UserService userService;
    

    @RequestMapping(method = RequestMethod.GET)
    public String index(Model model) {
        return "login";
    }

    @RequestMapping(method = RequestMethod.POST)
    public String login(Model model, @ModelAttribute User user) {
        
        userService.login(user);
        
        return "index";
    }
}
